/** 
  *@CopyRight(c)2009 company Co.Ltd. 
  *@All right reserved.
  *@module name: App.Base.SystemManage.SystemModulesManage
  *@description:
  *
  *@author: lugj
  *@version: 1.0
  *@date: 2009/06/18
  *@last date: 2009/07/15
  *@history:
    1.
    2.
  *@bugs:
    1. 
    2. 
  *
*/ 

Ext.namespace("App.Base.SystemManage");

//SystemModulesManage Class
//config: {id: , }
App.Base.SystemManage.SystemModulesManage = function(config){

	//generating the global unique id.
	this.config = config;

	this.MODULE_ID = App.Base.Common.func.generateGlobalUniqueId(this.config, 'SYSMODMGR');

	//defined constants.

	this.OpCmd = App.Base.common.param.OP_CMD_NONE;

	this.curSelModId = App.Base.common.param.INVALIDATE_ID;
	this.curSelModOldPId = App.Base.common.param.INVALIDATE_ID;
	this.curSelModNewPId = App.Base.common.param.INVALIDATE_ID;

	//
	this.treePanelClick = function(node){
		node.select();

		if (node == null)
		{
			App.Base.Common.func.MESSAGEBOX_SHOW({
					title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
					msg: "系统发生错误：TreePanel选择的当前菜单项节点node为NULL",
					icon: Ext.MessageBox.ERROR
				});
			return;
		}

		if (!(node.isLeaf() || node.isExpanded()))
		{
			node.expand();
		}

		if (this.asyncTreeNode.id == node.id)
		{
			App.Base.Common.func.MESSAGEBOX_SHOW({
					title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
					msg: "系统不允许操作顶级根模块项",
					icon: Ext.MessageBox.ERROR
				});
			this.formPanel.getForm().reset();
			return;
		}

		this.curSelModId = node.id.substr(0, node.id.length - this.MODULE_ID.length);
		this.curSelModOldPId = node.parentNode.id.substr(0, node.parentNode.id.length - this.MODULE_ID.length);
		
		//这里初始化模块项配置界面
		Ext.getCmp('modName' + this.MODULE_ID).setRawValue(node.text);
		Ext.getCmp('modParentId' + this.MODULE_ID).setRawValue(this.curSelModOldPId + App.Base.common.param.SPLIT_CHARS_UNDELINE + node.parentNode.text);
		Ext.getCmp('modDesc' + this.MODULE_ID).setRawValue(node.attributes['qtip']);
		Ext.getCmp('leafNodeFlag' + this.MODULE_ID).setValue(node.isLeaf());
		Ext.getCmp('modNavUrl' + this.MODULE_ID).setRawValue(node.attributes['actionModuleConfig']);
		Ext.getCmp('expandImgUrl' + this.MODULE_ID).setRawValue(node.attributes['expandIcon']);
		Ext.getCmp('normalImgUrl' + this.MODULE_ID).setRawValue(node.attributes['icon']);
		Ext.getCmp('displayRankIndex' + this.MODULE_ID).setRawValue(node.attributes['displayRankIndex']);
		Ext.getCmp('sysHoldFlag' + this.MODULE_ID).setValue(node.attributes['sysHoldFlag'].trim() == '1' ? true:false);
	};

	this.treePanelRefresh = function(){
		var node = null;

		if (this.OpCmd == App.Base.common.param.OP_CMD_ADD)
		{
			node = this.tree.getNodeById(this.curSelModNewPId + this.MODULE_ID);
			if (!App.Base.Common.func.isUndefinedOrNull(node))
			{
				node.reload();
			}
		}
		else if (this.OpCmd == App.Base.common.param.OP_CMD_MODIFY)
		{
			node = this.tree.getNodeById(this.curSelModId + this.MODULE_ID);
			if (!App.Base.Common.func.isUndefinedOrNull(node))
			{
				node.remove();
			}

			node = this.tree.getNodeById(this.curSelModNewPId + this.MODULE_ID);
			if (!App.Base.Common.func.isUndefinedOrNull(node))
			{
				node.reload();
			}
		}
		else if (this.OpCmd == App.Base.common.param.OP_CMD_DELETE)
		{
			node = this.tree.getNodeById(this.curSelModId + this.MODULE_ID);
			if (!App.Base.Common.func.isUndefinedOrNull(node))
			{
				node.remove();
			}
		}	
	};

	this.winHandler = function(win, node){
		if (win.action == '2')
		{
			this.OpCmd = App.Base.common.param.OP_CMD_NONE;
			return;
		}

		if (node == null)
		{
			return;
		}

		var nodeId = node.id.substr(node.id, node.id.length - win.MODULE_ID.length);

		//删除
		if (this.OpCmd == App.Base.common.param.OP_CMD_DELETE)
		{
			if (App.Base.common.param.SYSMODMGR_TREE_ROOTNODE_ID == nodeId)
			{
				App.Base.Common.func.MESSAGEBOX_SHOW({
						title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
						msg: "系统不允许删除顶级根模块项",
						icon: Ext.MessageBox.ERROR
					});
				this.OpCmd = App.Base.common.param.OP_CMD_NONE;
				this.formPanel.getForm().reset();
				return;
			}			

			if (win.tree.getNodeById(nodeId + win.MODULE_ID).hasChildNodes())
			{
				App.Base.Common.func.MESSAGEBOX_SHOW({
					title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
					msg: "系统不允许删除有子模块的模块项",
					icon: Ext.MessageBox.ERROR
				});	
				this.OpCmd = App.Base.common.param.OP_CMD_NONE;
				this.formPanel.getForm().reset();
				return null;
			}

			Ext.MessageBox.show({
				title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
				msg: '确定要删除系统模块项 [' + node.text + ']',
				buttons: Ext.MessageBox.YESNO,
				icon: Ext.MessageBox.QUESTION,
				fn: function(btn){
					if (btn == 'yes')
					{
						this.curSelModId = nodeId;
						this.curSelModOldPId = node.parentNode.id.substr(node.parentNode.id, node.parentNode.id.length - win.MODULE_ID.length);
						this.doRequest();
					}
					else
					{
						this.OpCmd = App.Base.common.param.OP_CMD_NONE;
					}
				},
				scope: this
			});	

			return;
		}
		
		if (node.isLeaf())
		{
			App.Base.Common.func.MESSAGEBOX_SHOW({
				title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
				msg: "模块项的上级模块分类不能为模块项节点",
				icon: Ext.MessageBox.ERROR
			});

			return;
		}

		//新增/修改
		Ext.getCmp('modParentId' + this.MODULE_ID).setRawValue(nodeId + App.Base.common.param.SPLIT_CHARS_UNDELINE + node.text);	
	};

	this.getRequestParams = function(){
		
		this.curSelModNewPId = Ext.getCmp('modParentId' + this.MODULE_ID).getRawValue().trim().split(App.Base.common.param.SPLIT_CHARS_UNDELINE)[0];

		var modId = this.curSelModId;
		var modName = Ext.getCmp('modName' + this.MODULE_ID).getRawValue().trim();	
		var modParentId = this.curSelModNewPId;	
		var modDesc = Ext.getCmp('modDesc' + this.MODULE_ID).getRawValue().trim();
		var leafNodeFlag = Ext.getCmp('leafNodeFlag' + this.MODULE_ID).getValue() == true ? '1' : '0';
		var modNavUrl = Ext.getCmp('modNavUrl' + this.MODULE_ID).getRawValue().trim();	
		var expandImgUrl = Ext.getCmp('expandImgUrl' + this.MODULE_ID).getRawValue().trim();	
		var normalImgUrl = Ext.getCmp('normalImgUrl' + this.MODULE_ID).getRawValue().trim();	
		var displayRankIndex = Ext.getCmp('displayRankIndex' + this.MODULE_ID).getRawValue().trim();	
		var sysHoldFlag = Ext.getCmp('sysHoldFlag' + this.MODULE_ID).getValue() == true ? '1' : '0';

		//这里验证数据正确合理性
		var validate = true;

		if (leafNodeFlag == '1' ? App.Base.Common.func.isEmptyString(modNavUrl) : App.Base.Common.func.isEmptyString(expandImgUrl))
		{
			validate = false;
		}

		if (this.curSelModNewPId == App.Base.common.param.INVALIDATE_ID)
		{
			validate = false;
		}

		if (!(validate && this.formPanel.getForm().isValid()))
		{
			App.Base.Common.func.MESSAGEBOX_SHOW({
				title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
				msg: '模块项数据格式填写不正确',
				icon: Ext.MessageBox.ERROR
			});
			this.OpCmd == App.Base.common.param.OP_CMD_NONE;
			return null;		
		} 

		if (Ext.getCmp('modParentId' + this.MODULE_ID).getValue().trim().length == 0)
		{
			App.Base.Common.func.MESSAGEBOX_SHOW({
				title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
				msg: '请选择模块上级分类',
				icon: Ext.MessageBox.ERROR
			});
			this.OpCmd == App.Base.common.param.OP_CMD_NONE;
			return null;		
		} 

		//
		if (this.OpCmd == App.Base.common.param.OP_CMD_MODIFY)
		{
			if (this.tree.getSelectionModel().getSelectedNode() == null)
			{
				App.Base.Common.func.MESSAGEBOX_SHOW({
					title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
					msg: "请选择要进行修改的模块项节点",
					icon: Ext.MessageBox.ERROR
				});	
				this.OpCmd == App.Base.common.param.OP_CMD_NONE;
				return null;
			}

			if (modId == App.Base.common.param.SYSMODMGR_TREE_ROOTNODE_ID)
			{
				App.Base.Common.func.MESSAGEBOX_SHOW({
						title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
						msg: "系统不允许操作模块目录树的模块项根节点",
						icon: Ext.MessageBox.ERROR
					});
				this.OpCmd == App.Base.common.param.OP_CMD_NONE;
				return null;
			}

			if (modId == modParentId)
			{
				App.Base.Common.func.MESSAGEBOX_SHOW({
					title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
					msg: "模块项的上级模块分类不能为本模块分类节点",
					icon: Ext.MessageBox.ERROR
				});	
				this.OpCmd == App.Base.common.param.OP_CMD_NONE;
				return null;
			}

			if (Ext.getCmp('leafNodeFlag' + this.MODULE_ID).getValue() && this.tree.getNodeById(modId + this.MODULE_ID).hasChildNodes())
			{
				App.Base.Common.func.MESSAGEBOX_SHOW({
					title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
					msg: "系统不允许修改有子模块的模块项为模块节点类型",
					icon: Ext.MessageBox.ERROR
				});	
				this.OpCmd == App.Base.common.param.OP_CMD_NONE;
				this.formPanel.getForm().reset();
				return null;
			}
		}

		//
		params = 'SYS_OP_CMD=' + encodeURIComponent(this.OpCmd) 
			+ '&MOD_ID=' + encodeURIComponent(modId)
			+ '&MOD_PARENT_ID=' + encodeURIComponent(modParentId)
			+ '&MOD_NAME=' + encodeURIComponent(modName)
			+ '&MOD_DESC=' + encodeURIComponent(modDesc)
			+ '&LEAF_NODE_FLAG=' + encodeURIComponent(leafNodeFlag)
			+ '&MOD_CFG_PATH=' + encodeURIComponent(modNavUrl)
			+ '&EXPAND_IMG_URL=' + encodeURIComponent(expandImgUrl)
			+ '&NORMAL_IMG_URL=' + encodeURIComponent(normalImgUrl)
			+ '&DISPLAY_RANK_INDEX=' + encodeURIComponent(displayRankIndex)
			+ '&SYS_HOLD_FLAG=' + encodeURIComponent(sysHoldFlag);
		
		return params;
	};

	this.handlerSuccess = function(response){
		Ext.getBody().unmask();
		//var result = decodeURIComponent(params.response.responseText);
		
		var result = Ext.decode(response.responseText);
		//{returnCode: , msg: );
		
		var icon = (result.returnCode == App.Base.common.param.REQ_SUCCESS) ? Ext.MessageBox.INFO:Ext.MessageBox.ERROR;

		App.Base.Common.func.MESSAGEBOX_SHOW({
			title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
			//msg: result.returnCode + '：'+ result.msg,
			msg: result.msg,
			icon: icon
		});
		
		if (result.returnCode == App.Base.common.param.REQ_SUCCESS)
		{
			if (!(this.OpCmd == App.Base.common.param.OP_CMD_GENERATE))
			{
				//自动更新系统模块目录树
				this.treePanelRefresh();
			}
		}
		//
		this.OpCmd = App.Base.common.param.OP_CMD_NONE;

		this.curSelModId = App.Base.common.param.INVALIDATE_ID;
		this.curSelModOldPId = App.Base.common.param.INVALIDATE_ID;
		this.curSelModNewPId = App.Base.common.param.INVALIDATE_ID;

		this.formPanel.getForm().reset();
	};

	this.handlerFailure = function(){
		Ext.getBody().unmask();
		App.Base.Common.func.MESSAGEBOX_SHOW({
			title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
			msg: '服务器请求操作失败，请稍候重试',
			icon: Ext.MessageBox.ERROR
		});	
	};

	this.doRequest = function(){
		var params = null;
		if (this.OpCmd == App.Base.common.param.OP_CMD_ADD || this.OpCmd == App.Base.common.param.OP_CMD_MODIFY)
		{
			params = this.getRequestParams();
		}
		else if (this.OpCmd == App.Base.common.param.OP_CMD_DELETE)
		{
			params = 'SYS_OP_CMD=' + encodeURIComponent(this.OpCmd) 
				+ '&MOD_ID=' + encodeURIComponent(this.curSelModId)
				+ '&MOD_PARENT_ID=' + encodeURIComponent(this.curSelModOldPId);
		}
		else if (this.OpCmd == App.Base.common.param.OP_CMD_GENERATE)
		{
			params = 'SYS_OP_CMD=' + encodeURIComponent(this.OpCmd);
		}

		if (params != null)
		{
			App.Base.Common.func.request({
				method: 'POST',
				url: App.Base.common.param.SYSMODMGR_OPERATION_DATAURL ,
				success: this.handlerSuccess,
				failure: this.handlerFailure,
				scope: this,
				params: params
			});
		}	
	};

	this.createSysSelUpMenusWin = function(){
		var title = '选择上级模块分类';
		var leaf = '0';
		if (this.OpCmd == App.Base.common.param.OP_CMD_DELETE)
		{
			title = '删除模块项';
			leaf = '2';
		}
		new App.Base.SystemManage.SystemSelectTreeWindow({
			id: this.MODULE_ID,
			title: title,
			leaf: leaf,
			asyncTreeNode: {
				id: App.Base.common.param.SYSMODMGR_TREE_ROOTNODE_ID,
				text: App.Base.common.param.SYSMODMGR_TREE_ROOTNODE_NORMAL_TITLE,
				icon: App.Base.common.param.SYSMODMGR_TREE_ROOTNODE_ICON_URL,
				expandIcon: App.Base.common.param.SYSMODMGR_TREE_ROOTNODE_EXPANDICON_URL,
				qtip: App.Base.common.param.SYSMODMGR_TREE_ROOTNODE_QTIP,
				singleClickExpand: true
			},
			dataUrl: App.Base.common.param.SYSMODMGR_ASYNC_TREELOADER_DATAURL,
			handler: function(o, node){
				if (o.action == App.Base.common.param.BUTTON_ACTION_OK)
				{
					this.winHandler(o, node);
				}
				else
				{
					this.OpCmd = App.Base.common.param.OP_CMD_NONE;
				}
			},
			scope: this
		}).getMainPanel().show();
	};

	//tree
	this.asyncTreeNode = new Ext.tree.AsyncTreeNode({
		id: App.Base.common.param.SYSMODMGR_TREE_ROOTNODE_ID + this.MODULE_ID,
		text: App.Base.common.param.SYSMODMGR_TREE_ROOTNODE_NORMAL_TITLE,

		icon: App.Base.common.param.SYSMODMGR_TREE_ROOTNODE_ICON_URL,
		expandIcon: App.Base.common.param.SYSMODMGR_TREE_ROOTNODE_EXPANDICON_URL,
		qtip: App.Base.common.param.SYSMODMGR_TREE_ROOTNODE_QTIP
	});
	
	this.tree = new Ext.tree.TreePanel({
		id: 'tree' + this.MODULE_ID,

		autoScroll: true,

		root: this.asyncTreeNode,

		loader: new Ext.tree.TreeLoader({
			dataUrl: App.Base.common.param.SYSMODMGR_ASYNC_TREELOADER_DATAURL,
			baseParams: {
				module: this.MODULE_ID
			}
		})
	});

	this.tree.on("beforeexpandnode", function(node){
		if (node != null)
		{
			node.select();
			node.setIcon(node.attributes['expandIcon']);				
		}
	});

	this.tree.on("beforecollapsenode", function(node){
		if (node != null)
		{
			node.select();
			node.setIcon(node.attributes['icon']);				
		}
	});

	this.tree.on("click", this.treePanelClick, this);

    this.contextmenu = new Ext.menu.Menu({
		id: 'contextmenu' + this.MODULE_ID,
		items: [{
			id: 'ctxExpand' + this.MODULE_ID,
			text: '展开目录节点',
			iconCls: 'x-menu-mainframe-expand'
		}, {
			id: 'ctxCollapse' + this.MODULE_ID,
			text: '折叠目录节点',
			iconCls: 'x-menu-mainframe-collapse'
		}, '-', {
			id: 'ctxReload' + this.MODULE_ID,
			text: '重载目录节点',
			iconCls: 'x-menu-mainframe-refresh'
		}],
		listeners: {
			click: function(menu, menuItem, e){
				this.contextmenu.hide();
			   
				var menuItemId = menuItem.getId();
				
				var node = this.tree.getSelectionModel().getSelectedNode();

				switch(menuItemId)
				{
					case 'ctxExpand' + this.MODULE_ID:
						node.expand();
						break;
					case 'ctxCollapse' + this.MODULE_ID:
						node.collapse();
						break;
					case 'ctxReload' + this.MODULE_ID:
						node.reload();
						break;
					default:
						break;
				}
					   
			}, 
			scope: this
		}
	});
            
	this.tree.on("contextmenu", function(node, e){
		e.preventDefault();
		
		node.select();

		if (!node.isLeaf())
		{
			this.contextmenu.showAt(e.getXY());
		}
	}, this);

	this.asyncTreeNode.expand();

    this.formPanel = new Ext.FormPanel({
		id: 'formPanel' + this.MODULE_ID,
		autoDestroy: true,
		border: false,
		tbar: new Ext.Toolbar({
			id: 'tbar' + this.MODULE_ID ,
			border: false,
			items : ['->','-',{
				id: 'tbarMenusRefresh' + this.MODULE_ID,
				text:'<font color="red">更新模块缓存</font>',
				iconCls: 'x-menu-mainframe-refresh',
				tooltip: {title: '提示：', text: '系统模块缓存文件的生成顺序是按照"模块项排序序号"降序生成，更新之前请正确配置模块参数'},
				handler: function(){

					Ext.MessageBox.show({
						title: App.Base.common.param.MESSAGEBOX_NORMAL_TIPS,
						msg: '确定要更新系统模块配置文件缓存',
						buttons: Ext.MessageBox.YESNO,
						icon: Ext.MessageBox.QUESTION,
						fn: function(btn){
							if (btn == 'yes')
							{	
								Ext.getBody().mask("系统正在更新模块配置缓存文件，请稍候...", "x-mask-loading");
								this.OpCmd = App.Base.common.param.OP_CMD_GENERATE;
								this.doRequest();
							}
							else
							{
								this.OpCmd = App.Base.common.param.OP_CMD_NONE;
							}
						},
						scope: this
					});	
				},
				scope: this
			}, '-', {
				id: 'tbarMenusAdd' + this.MODULE_ID,
				text:'<font color="blue">新增模块项</font>',
				iconCls: 'x-menu-personinfolist-add',
				//tooltip: {title:'Tip Title', text:'This is a an example QuickTip for a toolbar item'},
				//enableToggle: true,
				handler: function(){
					this.OpCmd = App.Base.common.param.OP_CMD_ADD;
					this.doRequest();
				},
				scope: this
			}, '-', {
				id: 'tbarMenusModify' + this.MODULE_ID,
				text:'<font color="blue">修改模块项</font>',
				iconCls: 'x-menu-systemmenusmanage-modify',
				handler: function(){
					this.OpCmd = App.Base.common.param.OP_CMD_MODIFY;
					this.doRequest();
				},
				scope: this
			}, '-', {
				id: 'tbarMenusDelete' + this.MODULE_ID,
				text:'<font color="blue">删除模块项</font>',
				iconCls: 'x-menu-personinfolist-delete',
				handler: function(){
					this.OpCmd = App.Base.common.param.OP_CMD_DELETE;
					this.createSysSelUpMenusWin();
				},
				scope: this
			}, '-', {
				id: 'tbarMenusReset' + this.MODULE_ID,
				text:'<font color="blue">重置表单</font>',
				iconCls: 'x-menu-systemmenusmanage-rset',
				handler: function(){
					this.OpCmd = App.Base.common.param.OP_CMD_NONE;
					this.formPanel.getForm().reset();
					},
				scope: this
			},'-'
			]
		}),

		layout: 'border',
		items: [{
			region:'west',
			id: 'formPanelWest' + this.MODULE_ID,

			title : '系统模块目录树',
			width : 240,
			minWidth: 220,
			border: false,
			autoScroll: true,

			split : true,
			collapsible : true,
			bodyStyle:'padding:5px 5px 5px 0',

			layout: 'fit',
			items: [this.tree]
		},{
			region:'center',
			id: 'formPanelCenter' + this.MODULE_ID,

			frame: true,
			border: false,
			autoScroll: true,

			defaults: {width: 620},
			defaultType: 'textfield',

			labelAlign: 'top',
			labelWidth: 128,
			bodyStyle:'padding:5px 5px 5px 0',

			layout: 'form',
			items :[{
				id: 'modName' + this.MODULE_ID,
				name: 'modName' + this.MODULE_ID,
				fieldLabel: '<font color="#FF0000">模块项名称(必填)</font>',
				maskRe: eval(App.Base.common.param.TEXTFIELD_INPUT_MASKRE),
				regex: eval(App.Base.common.param.TEXTFIELD_INPUT_REGEX),
				regexText: App.Base.common.param.TEXTFIELD_INPUT_REGEX_TIPS,
				allowBlank: false
			},
			new Ext.Button({
				id: 'btnSelectSysModulesParentMod' + this.MODULE_ID,
				text: '<font color="#FF0000">选择上级模块分类(必选)</font>',

				handler: function(){
					this.createSysSelUpMenusWin();
				},
				scope: this
			})
			, {
				id: 'modParentId' + this.MODULE_ID,
				name: 'modParentId' + this.MODULE_ID,
				fieldLabel: '<font color="red">上级模块分类ID' + App.Base.common.param.SPLIT_CHARS_UNDELINE + '名称(必填)</font>',
				readOnly: true,
				disabled: true,
				hideLabel: true,
				maskRe: eval(App.Base.common.param.TEXTFIELD_INPUT_MASKRE),
				regex: eval(App.Base.common.param.TEXTFIELD_INPUT_REGEX),
				regexText: App.Base.common.param.TEXTFIELD_INPUT_REGEX_TIPS,
				allowBlank: false,
				emptyText : '请选择上级模块分类...'
			}, {
				id: 'modDesc' + this.MODULE_ID,
				name: 'modDesc' + this.MODULE_ID,
				fieldLabel: '<font color="red">模块项描述<font>',
				maskRe: eval(App.Base.common.param.TEXTFIELD_INPUT_MASKRE),
				regex: eval(App.Base.common.param.TEXTFIELD_INPUT_REGEX),
				regexText: App.Base.common.param.TEXTFIELD_INPUT_REGEX_TIPS

			}, {
				xtype: 'fieldset',
				id: 'fieldset01' + this.MODULE_ID,
				title: '模块项创建为模块节点',
				collapsible: true,
				collapsed: false,
				autoHeight: true,
				
				labelAlign: 'top',
				labelWidth: 128,
				layout: 'form',
				items: [{
					xtype: 'checkbox',
					id: 'leafNodeFlag' + this.MODULE_ID,
					name: 'leafNodeFlag' + this.MODULE_ID,
					hideLabels: true,
					fieldLabel: '<font color="red">请选择</font>',
					boxLabel: '<font color="red">创建为模块项节点</font>',
					listeners: {
						check: function(checkbox, checked){
							var o1 = Ext.getCmp('modNavUrl' + this.MODULE_ID);
							var o2 = Ext.getCmp('expandImgUrl' + this.MODULE_ID);

							if (checked)
							{
								o1.setDisabled(false);
								o2.setDisabled(true);
								o2.setRawValue('');
								//o1.focus();
							}
							else 
							{
								o2.setDisabled(false);
								o1.setDisabled(true);
								o1.setRawValue('');
								//o2.focus();
							}
						},
						scope: this
					}
				}, {
					xtype: 'textfield',
					id: 'modNavUrl' + this.MODULE_ID,
					name: 'modNavUrl' + this.MODULE_ID,
					width: 596,
					fieldLabel: '<font color="red">模块项节点的配置文件(如果是创建模块节点，必填)</font>',
					maskRe: eval(App.Base.common.param.TEXTFIELD_INPUT_MASKRE),
					regex: eval(App.Base.common.param.TEXTFIELD_INPUT_REGEX),
					regexText: App.Base.common.param.TEXTFIELD_INPUT_REGEX_TIPS,
					disabled: true
				}, {
					xtype: 'textfield',
					id: 'expandImgUrl' + this.MODULE_ID,
					name: 'expandImgUrl' + this.MODULE_ID,
					width: 596,
					fieldLabel: '<font color="red">模块分类节点在目录树展开时的图标URL路径(如果是创建模块分类节点，必填)</font>',
					maskRe: eval(App.Base.common.param.TEXTFIELD_INPUT_MASKRE),
					regex: eval(App.Base.common.param.TEXTFIELD_INPUT_REGEX),
					regexText: App.Base.common.param.TEXTFIELD_INPUT_REGEX_TIPS
				}]
			}, {
				xtype: 'fieldset',
				id: 'fieldset02' + this.MODULE_ID,
				title: '模块项配置',
				collapsible: true,
				collapsed: false,
				autoHeight: true,
				
				labelAlign: 'top',
				labelWidth: 128,
				layout: 'form',
				items: [{
					xtype: 'textfield',
					id: 'normalImgUrl' + this.MODULE_ID,
					name: 'normalImgUrl' + this.MODULE_ID,
					width: 596,
					fieldLabel: '<font color="red">模块项在目录树中显示的正常图标URL路径(必填)</font>',
					maskRe: eval(App.Base.common.param.TEXTFIELD_INPUT_MASKRE),
					regex: eval(App.Base.common.param.TEXTFIELD_INPUT_REGEX),
					regexText: App.Base.common.param.TEXTFIELD_INPUT_REGEX_TIPS,
					allowBlank: false
				}, {
					xtype: 'textfield',
					id: 'displayRankIndex' + this.MODULE_ID,
					name: 'displayRankIndex' + this.MODULE_ID,
					value: '0',
					width: 596,
					fieldLabel: '<font color="red">模块项排序序号(必填 模块目录树为降序排列，该序号同时作为缓存文件的生成顺序号)</font>',
					regex: /^-?\d+$/,
					regexText:"只能够输入数字(最多16位)", 
					maxLength: 16, 
					allowBlank: false
				}, {
					xtype: 'checkbox',
					id: 'sysHoldFlag' + this.MODULE_ID,
					name: 'sysHoldFlag' + this.MODULE_ID,
					hideLabels: true,
					fieldLabel: '<font color="red">模块项是否标记为系统模块</font>',
					boxLabel: '<font color="red">是</font>'
				}]
			}]
		}]
	});

	this.formPanel.doLayout();

	//defined methods.
    if((typeof App.Base.SystemManage.SystemModulesManage.SIMULATE_SHARED_METHODS_FLAG) == "undefined")
    {
        App.Base.SystemManage.SystemModulesManage.SIMULATE_SHARED_METHODS_FLAG = true;   

        App.Base.SystemManage.SystemModulesManage.prototype.getMainPanel = function(){   
            return this.formPanel;  
        };
 
        //simulating the class's constructor().
        var __ctor = function(){
            //alert('called __constructor() ok.');
        }();

    }
}